package com.tiancheng.trade.payment.task.ums.bo;

import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;
import java.util.List;

/**
 * txt解析内容
 */
@Getter
@Setter
public class FileRetBo {
    /**
     * txt文件名称
     */
    private String fileName;
    /**
     * txt文件内容
     */
    private Object[][] data;

    /**
     * 文件下载地址
     */
    private String downloadPath;

    public FileRetBo(String txtName, Object[][] data,String downloadPath) {
        this.fileName = txtName;
        this.data = data;
        this.downloadPath = downloadPath;
    }

    /**
     * 获取文件行
     * @param begin 开始行
     * @param end 结束行
     * @return
     */
    public List<Object[]> getRowData(int begin,int end){
        if(end==0 ||data==null ||data.length==0){
            return null;
        }
        if(end>data.length){
            end=data.length;
        }
        Object[][] objects = Arrays.copyOfRange(data, begin, end);
        return Arrays.asList(objects);
    }

}
